package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Proxy;

@Entity
@Table(name="depositos")
@Proxy (lazy = false)
public class DepositoEntity implements Serializable{

	@Transient
	private static final long serialVersionUID = 1L;

	@Id @GeneratedValue
	private Integer id;
	private String tipo;
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name="idDeposito")
	private List<ItemDepositoEntity> insumos = new ArrayList<ItemDepositoEntity>();


	public DepositoEntity() {
	}

	public DepositoEntity(String tipo) {
		this.tipo = tipo;
	}




	public Integer getId() {
		return id;
	}


	public void setId(Integer id) {
		this.id = id;
	}


	public String getTipo() {
		return tipo;
	}


	public void setTipo(String tipo) {
		this.tipo = tipo;
	}


	public List<ItemDepositoEntity> getInsumos() {
		return insumos;
	}


	public void setInsumos(List<ItemDepositoEntity> insumos) {
		this.insumos = insumos;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((insumos == null) ? 0 : insumos.hashCode());
		result = prime * result + ((tipo == null) ? 0 : tipo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DepositoEntity other = (DepositoEntity) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (insumos == null) {
			if (other.insumos != null)
				return false;
		} else if (!insumos.equals(other.insumos))
			return false;
		if (tipo == null) {
			if (other.tipo != null)
				return false;
		} else if (!tipo.equals(other.tipo))
			return false;
		return true;
	
	}	
}	
